package com.test.daily.leetcode.y2021.m11.day1102;

/**
 * @descriptions: DeleteGivenNode
 * @author: Tom
 * @date: 2021/11/2 上午 08:48
 * @version: 1.0
 */
public class Code01_DeleteGivenNode {

    public static void main(String[] args) {
        Code01_DeleteGivenNode cd = new Code01_DeleteGivenNode();
        ListNode head = new ListNode(4);
        head.next =  new ListNode(5);
        head.next.next =  new ListNode(1);
        head.next.next.next =  new ListNode(9);
        cd.deleteNode(head.next);
        cd.readListNode(head);
    }
    public void readListNode(ListNode root){
        ListNode cur = root;
        while(cur != null){
            System.out.print(cur.val + " ");
            cur = cur.next;
        }
    }
    public void deleteNode(ListNode node) {

        node.val = node.next.val;
        node.next = node.next.next;

    }
}
class ListNode{
    int val;
    ListNode next;
    public ListNode(int value){
        this.val = value;
    }
}
